<template lang="pug">
  kalix-dialog.user-add(title='编辑' bizKey="configteacher" ref="kalixBizDialog" v-bind:formModel.sync="formModel" v-bind:targetURL="targetURL")
    div.el-form(slot="dialogFormSlot")
      el-form-item(label="阅卷人" prop="name" v-bind:label-width="labelWidth" )
        el-input(v-model="formModel.name" v-bind:disabled="true")
      el-form-item(label="考试" prop="examName" v-bind:label-width="labelWidth" )
        el-input(v-model="formModel.examName" v-bind:disabled="true")
      el-form-item(label="考试科目" prop="subject" v-bind:label-width="labelWidth" )
        el-input(v-model="formModel.subject" v-bind:disabled="true")
      el-form-item(label="阅卷人职务" prop="teacherType" v-bind:label-width="labelWidth" v-bind:rules="rules.teacherType")
        <!--kalix-object-select2(v-model="formModel.teacherType" v-bind:objectsUrl="paperTagetURL"-->
        <!--v-bind:label="'title'" v-on:objectSelected="setPaperVal")-->
        kalix-dict-select(v-model="formModel.teacherType" appName="exam" dictType="阅卷教师")
      el-form-item.s-flex_item(label="评分权重" prop="scoreWeight" v-bind:rules="rules.scoreWeight" v-bind:label-width="labelWidth")
        el-input(v-model="formModel.scoreWeight")
</template>

<script type="text/ecmascript-6">
  import FormModel from './configTeacherModel'
  import {ExamTeacherURL, ExamPaperURL} from '../config.toml'

  export default {
    name: 'ConfigTeacherEdit',
    data() {
      var checkSimilarity = (rule, value, callback) => {
        if (!value) {
          return callback(new Error('请输入评分权重'));
        }
        if (/^(0.\d+|0|1)$/.test(value)) {
          callback();
        } else {
          callback(new Error('请输入0～1之间的数字值'));
        }
      };
      return {
        formModel: Object.assign({}, FormModel),
        labelWidth: '180px',
        rules: {
          teacherType: [{ required: true, message: '请选择阅卷人职务', trigger: 'change'}],
          scoreWeight: [{required: true, validator: checkSimilarity, trigger: 'blur'}]
        },
        targetURL: ExamTeacherURL
        // paperTagetURL: ExamPaperURL
      }
    }
  }
</script>

<style scoped>

</style>
